
const num = 10
// import qs from 'qs'
// import axios from 'axios'
import { export_json_to_excel } from "../../vendor/Export2Excel";

const disposeFile = function(fileList){
    for(var i in fileList){
        fileList[i].url = fileList[i].response
    }
    return fileList
}
const timeStampToTime = function(timeStamp){
    let date = new Date(timeStamp * 1000);
    let year = date.getFullYear();
    let month = date.getMonth()+1;
    month = this.checkTime(month);
    let day = date.getDate();
    day = this.checkTime(day);
    let H = date.getHours();
    H = this.checkTime(H);
    let M = date.getMinutes();
    M = this.checkTime(M);
    let S = date.getSeconds();
    S = this.checkTime(S);
    return `${year}-${month}-${day} ${H}:${M}:${S}`
}
const checkTime = function(time){
    let date = time>=10?time:'0'+time
    return date
}
const timeToTimestamp = function(time){
    let stringTime = time;
    let timeStamp = Math.round(new Date(stringTime) / 1000)
    return timeStamp
}

const timestampToDate = function(timestamp){
    let date = new Date(timestamp * 1000);
    let year = date.getFullYear();
    let month = date.getMonth()+1;
    month = this.checkTime(month);
    let day = date.getDate();
    day = this.checkTime(day);
    return `${year}${month}${day}`
}

//导出表格
// const exportExcel = function(tableHeader,tableName,data){
//     let letter = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
//     let formData = qs.stringify({
//         letter:letter,
//         tableheader:tableHeader,
//         data:data,
//         pro:tableName
//     })
//     axios.post('https://yx.tfnhg.com/Api/Excel/ce',formData)
//         .then(res =>{
//             console.log(res);
//             if(res.status == 200){
//                 window.location.href = "https://yx.tfnhg.com/add_excel?id="+res.data
//             }
//
//         })
// }

const exportExcel01 = function(header,filename,data){
    export_json_to_excel({
        header:header,
        data:data,
        filename:filename,
        autoWidth : true,
    })
}
export default {
    num : num,
    disposeFile: disposeFile,
    timeStampToTime:timeStampToTime,
    checkTime:checkTime,
    timeToTimestamp:timeToTimestamp,
    // exportExcel:exportExcel,
    timestampToDate:timestampToDate,
    exportExcel01:exportExcel01
}
